<template>
	<view class="beijingse">
		<!-- 筛选弹出层 -->
		<u-popup :show="show" @close="close" mode="bottom" :round="10">
			<view class="mainpadding">
				<view class="titletext textcenter">筛选</view>
				<view class="margin_top strongtext">时间</view>
				<view class="flexleft flex_wrap">
					<view class="flexcenter sanshi margin_top2" v-for="item in timeList" 
						@click="selecTimeBtn(item.id)">
						<view :class="item.id==selecttime?'haungsebtn':'huisebtn'">{{item.name}}</view>
					</view>
				</view>
				<!-- 时间 -->
				<view class="margin_top strongtext">自定义时间</view>
				<view class="flexcenter margin_top2" @click="zdysj">
					<view class="shijianbtn margin_right3" @click="zshijian">{{startime}}</view>
					<view class="xian margin_right3"></view>
					<view class="shijianbtn" @click="yshijian">{{endtime}}</view>
				</view>
				<u-datetime-picker :show="zshow" @confirm="zconfirm" v-model="value1" mode="date"
					@cancel="zshow= false"></u-datetime-picker>
				<u-datetime-picker :show="yshow" @confirm="yconfirm" v-model="value2" mode="date" @cancel="yshow= false"
					:minDate="minDate"></u-datetime-picker>
				<view class="bigbtn margin_top" @click="close">确认</view>
			</view>
		</u-popup>
		<!-- <view class="block1 mainpadding">
			<view class="flexbetween">
				<view class="ershib">合计：
					<text class="chanpinse">￥{{5780}}</text>
				</view>
				<view class="flexright" @click="show = true">
					<view class="nostrongtext margin_right1">筛选</view>
					<view class="xiasanjiao"></view>
				</view>
			</view>
		</view> -->
		<view class="ffffff mainpadding2" v-if="list.data.length">
			<view class="xiahuaxian padding_top" v-for="item in list.data" :key="item.id">
				<view class="flexbetween ">
					<view class="chanpinse">{{item.price}}</view>
					<view class="huisetext" v-show="item.status==1">已到账</view>
					<view class="huisetext" v-show="item.status==2">提现失败</view>
					<view class="huisetext" v-show="item.status==0">待审核</view>
				</view>
				<view class="huisetext margin_top1">{{item.createtime_text}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				// 时间
				startime: "开始时间",
				endtime: "结束时间",
				// 数据列表
				show: false,
				minDate: "",
				//开始时间
				zshow: false,
				value1: Number(new Date()),
				//结束
				yshow: false,
				value2: Number(new Date()),
				// 筛选
				timeList: [{
						id: 1,
						name: "今日"
					},
					{
						id: 2,
						name: "昨日"
					},
					{
						id: 3,
						name: "本月"
					},
					{
						id: 4,
						name: "上月"
					}
				],
				selecttime: 0, //筛选时间类型
				page: 1,
				limit: 12,
				list: {
					data: [{
						bonus_price:"",
						integral_price:"",
						token_price: "",
						voucher_price: "",
						memo:"",
						createtime_text:"",
					}]
				},
				valueType: 1, //1奖金，2积分，3通证，4本金，5收益
			}
		},
		onLoad(options) {
			this.valueType = options.type
		},
		onShow() {
			this.init()
		},
		methods: {
			// 热门推荐列表
			init(isPage, page) {
				let _this = this;
				httpRequest.request('/api/user/getWithdrawalList', 'POST', {
					start_time: this.startime=="开始时间"?'':this.startime,
					end_time: this.endtime=="开始时间"?'':this.endtime,
					page: page || 1,
					limit: _this.limit,
					sx_type:this.selecttime,
					hb_type:this.valueType==4||this.valueType==5?4:this.valueType
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			zdysj() {
				this.selecttime = 0
			},
			// 选择时间段
			selecTimeBtn(id) {
				this.mindate = ""
				this.selecttime = id
				this.startime = "开始时间"
				this.endtime = "结束时间"
			},
			// 跳转提现详情
			txxq(id) {
				uni.navigateTo({
					url: '/pages/mypage/tixianxq?id=' + id
				})
			},
			date(timer) {
				var date = new Date(timer); //当前时间
				var year = date.getFullYear() //返回指定日期的年份
				var month = repair(date.getMonth() + 1); //月
				var day = repair(date.getDate()); //日
				var curTime = year + "-" + month + "-" + day

				function repair(i) {
					if (i >= 0 && i <= 9) {
						return "0" + i;
					} else {
						return i;
					}
				}
				return curTime
			},
			// 开始时间
			zconfirm(e) {
				console.log(e)
				this.minDate = e.value
				this.startime = this.date(e.value)
				this.zshow = false
			},
			zshijian() {
				this.zshow = true
			},
			//结束时间
			yconfirm(e) {
				console.log(e)
				this.endtime = this.date(e.value)
				this.yshow = false
			},
			yshijian() {
				if (this.minDate == "") {
					httpRequest.toast("请选择开始时间")
					return
				}
				this.yshow = true
			},
			close() {
				// this.init()
				this.show = false
				// console.log('close');
			}
		}
	}
</script>
<style lang="scss" scoped>
	.chanpinse{
		font-size: 32rpx;
		font-family: DIN Next LT Pro-Bold, DIN Next LT Pro;
		font-weight: bold;
		color:#FAB536;
	}
	.kym{
		margin:250rpx auto 0;
		width: 343rpx;
		height: 324rpx;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.xian {
		width: 22rpx;
		height: 0rpx;
		background-color: #999999;
		border: 1rpx solid #999999;
	}

	.shijianbtn {
		padding: 20rpx 65rpx;
		background: #F7F9FA;
		border-radius: 41rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.huisebtn {
		width: 198rpx;
		height: 80rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
		background: #F7F9FA;
		border-radius: 41rpx;
	}

	.haungsebtn {
		width: 198rpx;
		height: 80rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #EF8933;
		background: rgba(239, 137, 51, .1);
		border-radius: 41rpx;
	}

	.sanshi {
		width: 33.33%;
	}
</style>
<style lang="scss" scoped>
	.huisetext {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.xiahuaxian:last-child {
		padding-bottom: 0rpx;
		border-bottom: none;
	}

	.xiahuaxian {
		padding-bottom: 30rpx;
		border-bottom: 2rpx solid rgba(0, 0, 0, 0.05);
	}

	.bigcstext {
		font-size: 32rpx;
		font-family: DIN Next LT Pro-Bold, DIN Next LT Pro;
		font-weight: bold;
		color:#FAB536;
	}

	.xiasanjiao {
		width: 12rpx;
		height: 10rpx;
		background-size: 100% 100%;
		background-image: url('../../static/image/system/shaixuan.png');
	}
.ershib{
	font-size: 28rpx;
	font-family: PingFang SC-Medium, PingFang SC;
	font-weight: 500;
	color: #000000;
}
	.chengsetext {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FAB536;
	}
</style>
